﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using TestEnvirementCL.Concrete;
using TestEnvirementCL.POCO;
using System.Reflection;

namespace TestEnvirementMVC.Controllers
{
    public class NSSFController : Controller
    {
      private EFDbContext db = new EFDbContext();

      //
      // GET: /NSSF/

      public ActionResult Index()
      {
        var nssfs = db.NSSFs.ToList<NSSF>();
        var schools = db.Schools.ToList<School>();

        MyChart test = new MyChart();
        String startupPath = Assembly.GetAssembly(typeof(MyChart)).Location;

        test.initialiseDataSerieArray(nssfs.Count);
        for (int i = 0; i < nssfs.Count; i++)
        {
          test.countPerName[i] = test.nieuweRij(nssfs[i].Name, nssfs[i].Schools.Count);
        }

        ViewBag.ListNSSF = test.countPerName;
        ViewBag.ListSchools = schools;
        ViewBag.ListNSSFs = nssfs;
        ViewBag.Message = "Google Charts Graphs";

        return View();
      }

      public ActionResult Alternative()
      {
        Dictionary<String,int> meetingsPerNSSF=new Dictionary<string,int>();
        db.NSSFs.ToList<NSSF>().ForEach(x => meetingsPerNSSF.Add(x.Name, x.Meetings.Count));
        ViewBag.MeetingsPerNSSF = meetingsPerNSSF;
        return View();
      }
    }
}
